package com.ruoyi.fangyuan.controller;


import com.ruoyi.common.core.web.controller.BaseController;

import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.fangyuan.domain.TFangyuantu;


import com.ruoyi.fangyuan.service.TFangyuantuService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

@Slf4j
@RestController
@RequestMapping("/tu")
public class FangTaiTuController extends BaseController {

    @Autowired
    TFangyuantuService fangtaiService;




    @PostMapping("add")
    public AjaxResult add(@RequestBody TFangyuantu fangtai){
        System.out.println (fangtai+"房态图" );
        return toAjax(fangtaiService.save(fangtai));
    }
    @RequestMapping("list")
    public List<TFangyuantu> list(){
        List<TFangyuantu> list = fangtaiService.list();
        return list;
    }



    @RequestMapping("file")
    public String file(MultipartFile file) throws IOException {
        System.out.println ("file"+file );
        if (null!=file && file.getSize()>0){
            String filename = file.getOriginalFilename();
            String s = UUID.randomUUID() + filename.substring(filename.lastIndexOf("."));
            File file1 = new File("D:\\pic\\", s);
            file.transferTo(file1);
            return "/pic/"+s;
        }
        return null;
    }
















//    /**
//     * 列表 - 条件查询
//     */
//    @RequestMapping("/list")
//    public TableDataInfo list(RoomInfoSearchFormRequestDto bean) {
//        // 房产类型 0 分散式 、1集中式 hostType
//       if (bean.getHostType ()==0){
//           log.info("{}:{}>>{}", "分散式" );
//           log.info("{}:{}>>{}", "分散式");
//           TbRoomInfoJzRequestDTO dto = new TbRoomInfoJzRequestDTO();
//           dto.setCity ( bean.getCity () );
//           dto.setCounty ( bean.getCounty ( ) );
//           dto.setProvince ( bean.getProvince ( ) );
//           dto.setPreName ( bean.getPreName ( ) );
//           dto.setFangtaiType ( bean.getFangtaiType ( ) );
//           List<FangTaiTuVo> list= tbRoomInfoService.ListFenTbRoom(dto);
//           return getDataTable (list);
//       }else {
//           log.info("{}:{}>>{}", "集中式" );
//           log.info("{}:{}>>{}", "集中式");
//           List<FangTaiTuVo> list= tbRoomInfoService.ListJzTbRoom(dto);
//
//           return getDataTable (list);
//
//       }
//    }
}
